# include "ShowRemoteWindow.h"
# include "MyDx11.h"

ShowRemoteWindow::ShowRemoteWindow(QWidget* parent)
	: QMainWindow(parent)
{
	QWidget::setAttribute(Qt::WA_PaintOnScreen); // 允许DX渲染 ...
	setFocusPolicy(Qt::WheelFocus); // 允许按键时间 ...
	setMouseTracking(true); // 允许鼠标移动 ...
	this->move(560, 240);
	auto s = this->size();
	// this->resize(parent->size());
	this->resize(920, 576);
	this->m_d3d11 = new MyDx11(reinterpret_cast<HWND>(this->winId()), this->width(), this->height());
	this->show();
	// this->setVisible(false);
}

void ShowRemoteWindow::addRemote(int _monitor_width, int _monitor_height)
{
}

void ShowRemoteWindow::copyToRemoteTexture(uint8_t* _buffer, size_t _size)
{
	if (_buffer == nullptr) {
		return;
	}
	this->m_d3d11->copyData(this->m_d3d11, _buffer, _size, "monitor");
}

void ShowRemoteWindow::rend() const
{
	this->m_d3d11->renderToTexture(false);
	this->m_d3d11->render();
}

ShowRemoteWindow::~ShowRemoteWindow()
{
	delete this->m_d3d11;
}

void ShowRemoteWindow::paintEvent(QPaintEvent* event)
{
}

void ShowRemoteWindow::resizeEvent(QResizeEvent* event)
{
	// this->m_d3d11->resize(this->width(), this->height());
}
